
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1. Qmake项目原理和手动配置Qtcreater · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="1.2.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Qt入门教程笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    一. Qt和qmake的配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.2.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    1. Qmake项目原理和手动配置Qtcreater
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    2. Qmake创建动态和静态链接库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    3. Qmake的版本设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../README_2.html">
            
                <a href="../README_2.html">
            
                    
                    二. Qt信号槽机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Chapter2/2.1.html">
            
                <a href="../Chapter2/2.1.html">
            
                    
                    1. Qt信号槽的概念
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../README_3.html">
            
                <a href="../README_3.html">
            
                    
                    三. QWidget的概念和使用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Chapter3/3.1.html">
            
                <a href="../Chapter3/3.1.html">
            
                    
                    1. QWidget的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Chapter3/3.2.html">
            
                <a href="../Chapter3/3.2.html">
            
                    
                    2. QWidget的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../README_4.html">
            
                <a href="../README_4.html">
            
                    
                    四. QString字符串类型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Chapter4/4.1.html">
            
                <a href="../Chapter4/4.1.html">
            
                    
                    1. QString概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Chapter4/4.2.html">
            
                <a href="../Chapter4/4.2.html">
            
                    
                    2. QString方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../README_5.html">
            
                <a href="../README_5.html">
            
                    
                    五. QLabel
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Chapter5/5.1.html">
            
                <a href="../Chapter5/5.1.html">
            
                    
                    1. QLabel的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Chapter5/5.2.html">
            
                <a href="../Chapter5/5.2.html">
            
                    
                    2. QLabel的创建和方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../README_6.html">
            
                <a href="../README_6.html">
            
                    
                    六. QPushButton
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Chapter6/6.1.html">
            
                <a href="../Chapter6/6.1.html">
            
                    
                    1. QPushButton的概念
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1. Qmake项目原理和手动配置Qtcreater</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="1-qmake&#x9879;&#x76EE;&#x539F;&#x7406;&#x548C;&#x624B;&#x52A8;&#x914D;&#x7F6E;qtcreater">1. Qmake&#x9879;&#x76EE;&#x539F;&#x7406;&#x548C;&#x624B;&#x52A8;&#x914D;&#x7F6E;Qtcreater</h1>
<h2 id="&#x4E00;-qt&#x6E90;&#x7801;&#x548C;&#x754C;&#x9762;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x5230;&#x7A0B;&#x5E8F;&#x7684;&#x7F16;&#x8BD1;&#x5206;&#x6790;">&#x4E00;. Qt&#x6E90;&#x7801;&#x548C;&#x754C;&#x9762;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x5230;&#x7A0B;&#x5E8F;&#x7684;&#x7F16;&#x8BD1;&#x5206;&#x6790;</h2>
<h3 id="qt&#x7A0B;&#x5E8F;&#x7F16;&#x8BD1;&#x7ECF;&#x5386;&#x7684;&#x6B65;&#x9AA4;">Qt&#x7A0B;&#x5E8F;&#x7F16;&#x8BD1;&#x7ECF;&#x5386;&#x7684;&#x6B65;&#x9AA4;</h3>
<ol>
<li>&#x7F16;&#x8BD1;.pro&#x6587;&#x4EF6;&#x751F;&#x4EA7;makefile</li>
<li>&#x4F7F;&#x7528;jom&#x6216;&#x8005;make&#x7F16;&#x8BD1;makefile<blockquote>
<p>  jom&#x6216;&#x8005;make</p>
<ol>
<li>&#x751F;&#x4EA7;&#x754C;&#x9762;&#x6E90;&#x7801;</li>
<li><code>uic widget.ui -o ui_widge.h</code></li>
<li>&#x751F;&#x6210;&#x4FE1;&#x53F7;&#x69FD;&#x4EE3;&#x7801;</li>
<li><code>moc widget moc_widget.cpp</code></li>
</ol>
</blockquote>
</li>
<li>&#x4ECE;&#x751F;&#x6210;&#x7684;&#x6E90;&#x7801;&#x7F16;&#x8BD1;&#x6210;&#x7A0B;&#x5E8F;<blockquote>
<ol>
<li>&#x9884;&#x5904;&#x7406;: &#x5934;&#x6587;&#x4EF6;&#x52A0;&#x8F7D;&#x548C;&#x5B8F;&#x5C55;&#x5F00;</li>
<li>&#x7F16;&#x8BD1;: .cpp&#x4EA7;&#x751F;&#x76EE;&#x6807;&#x6587;&#x4EF6;.o</li>
<li>&#x94FE;&#x63A5;: &#x94FE;&#x63A5;&#x4E8C;&#x8FDB;&#x5236;&#x4EE3;&#x7801;&#x5E93;</li>
<li>&#x6267;&#x884C;: exe dll so</li>
</ol>
</blockquote>
</li>
</ol>
<h2 id="&#x4E8C;-qmake&#x751F;&#x6210;makefile">&#x4E8C;. qmake&#x751F;&#x6210;makefile</h2>
<h3 id="pro&#x6587;&#x4EF6;&#x7684;&#x521B;&#x5EFA;">.pro&#x6587;&#x4EF6;&#x7684;&#x521B;&#x5EFA;</h3>
<pre><code>SOURCES += main.cpp \
           src1.cpp \
           head1.h
CONFIG += console
</code></pre><h3 id="&#x4F7F;&#x7528;qmake&#x5C06;pro&#x6587;&#x4EF6;&#x751F;&#x6210;makefile">&#x4F7F;&#x7528;qmake&#x5C06;.pro&#x6587;&#x4EF6;&#x751F;&#x6210;makefile</h3>
<blockquote>
<p>&#x66F4;&#x6362;qmake&#x7248;&#x672C;</p>
<pre><code>cd /usr/lib/x86_64-linux-gnu/qt-default/qtchooser
sudo nano default.conf
</code></pre><pre><code>qmake -o makefile testqmake.pro
</code></pre><p><strong>&#x6700;&#x540E;&#x4F7F;&#x7528;make&#x547D;&#x4EE4;&#x5373;&#x53EF;&#x751F;&#x4EA7;&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;</strong></p>
</blockquote>
<h2 id="&#x4E09;&#x4F7F;&#x7528;sh&#x811A;&#x672C;&#x6587;&#x4EF6;&#x6279;&#x91CF;&#x6267;&#x884C;">&#x4E09;.&#x4F7F;&#x7528;.sh&#x811A;&#x672C;&#x6587;&#x4EF6;&#x6279;&#x91CF;&#x6267;&#x884C;</h2>
<p>&#x521B;&#x5EFA;make.sh&#x6587;&#x4EF6;</p>
<pre><code>export PATH=/usr/lib/x86_64-linux-gnu/qt5/bin:$PATH
qmake -o makefile testqmake.pro
make
</code></pre><p>&#x8D4B;&#x4E88;&#x6267;&#x884C;&#x6743;&#x9650;</p>
<pre><code>chmod +x make.sh
</code></pre><p>&#x6267;&#x884C;<code>make.sh</code></p>
<pre><code>./make.sh
</code></pre><h2 id="&#x56DB;-&#x52A0;&#x8F7D;&#x5185;&#x90E8;&#x5E93;&#x548C;&#x5934;&#x6587;&#x4EF6;">&#x56DB;. &#x52A0;&#x8F7D;&#x5185;&#x90E8;&#x5E93;&#x548C;&#x5934;&#x6587;&#x4EF6;</h2>
<p>&#x52A0;&#x8F7D;&#x5185;&#x90E8;&#x5E93;</p>
<pre><code>&#x5728;.pro&#x6587;&#x4EF6;&#x4E2D;
QT += core gui
QT -= gui
</code></pre><p>&#x52A0;&#x8F7D;&#x5934;&#x6587;&#x4EF6;</p>
<pre><code>&#x5728;.pro&#x6587;&#x4EF6;&#x4E2D;
INCLUDEPATH += ../../include
INCLUDEPATH += &amp;$$PWD/../../include
</code></pre><blockquote>
<p>&#x56E0;&#x4E3A;qt&#x751F;&#x6210;&#x7684;&#x6700;&#x7EC8;&#x9879;&#x76EE;&#x6587;&#x4EF6;&#x662F;&#x5728;&#x4E0E;&#x6E90;&#x6587;&#x4EF6;&#x4E0A;&#x7EA7;&#x8DEF;&#x5F84;&#x540C;&#x7EA7;&#x522B;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x9762;&#x7684;,&#x6240;&#x4EE5;&#x5411;&#x8DEF;&#x5F84;&#x5916;&#x8FD4;&#x56DE;&#x4E24;&#x6B21;,&#x518D;&#x8FDB;&#x5165;include&#x6587;&#x4EF6;&#x5939;
<code>$$PWD</code>&#x4E3A;.pro&#x6587;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;</p>
</blockquote>
<h2 id="&#x4E94;-&#x5E93;&#x5F15;&#x7528;&#x548C;&#x5E93;&#x8DEF;&#x5F84;&#x6307;&#x5B9A;">&#x4E94;. &#x5E93;&#x5F15;&#x7528;&#x548C;&#x5E93;&#x8DEF;&#x5F84;&#x6307;&#x5B9A;</h2>
<pre><code>LIBS += -L../../lib -lopencv_world320
</code></pre><h2 id="&#x516D;-&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x8DEF;&#x5F84;&#x548C;&#x6587;&#x4EF6;&#x540D;">&#x516D;. &#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x8DEF;&#x5F84;&#x548C;&#x6587;&#x4EF6;&#x540D;</h2>
<p>&#x6307;&#x5B9A;&#x8DEF;&#x5F84;</p>
<pre><code>DESTDIR += ../../bin
</code></pre><p>&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x6587;&#x4EF6;&#x540D;</p>
<pre><code>TARGET = filename
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 一. Qt和qmake的配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="1.2.html" class="navigation navigation-next " aria-label="Next page: 2. Qmake创建动态和静态链接库">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1. Qmake项目原理和手动配置Qtcreater","level":"1.2.1","depth":2,"next":{"title":"2. Qmake创建动态和静态链接库","level":"1.2.2","depth":2,"path":"Chapter1/1.2.md","ref":"Chapter1/1.2.md","articles":[]},"previous":{"title":"一. Qt和qmake的配置","level":"1.2","depth":1,"path":"Chapter1/README.md","ref":"Chapter1/README.md","articles":[{"title":"1. Qmake项目原理和手动配置Qtcreater","level":"1.2.1","depth":2,"path":"Chapter1/1.1.md","ref":"Chapter1/1.1.md","articles":[]},{"title":"2. Qmake创建动态和静态链接库","level":"1.2.2","depth":2,"path":"Chapter1/1.2.md","ref":"Chapter1/1.2.md","articles":[]},{"title":"3. Qmake的版本设置","level":"1.2.3","depth":2,"path":"Chapter1/1.3.md","ref":"Chapter1/1.3.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Chapter1/1.1.md","mtime":"2019-06-01T06:27:58.627Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-07T12:23:15.547Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

